package com.example.actearly_revised;

import com.example.actearly_revised.R;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;

public class ModeSelect extends Activity {

	Button personalizeButton;
	Button quicklistButton;
	Button profileButton;
	View actionbarView;
	int profile_number = 1; 
	static User[] users;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_mode_select);
		LinearLayout pageLayout=(LinearLayout)findViewById(R.id.modeLayout);
		//pageLayout.setBackgroundResource(R.drawable.background);

		personalizeButton = (Button) findViewById(R.id.personalizeButton);
		quicklistButton = (Button) findViewById(R.id.quicklistButton);
		profileButton = (Button) findViewById(R.id.btnProfile);

		//change font/color/text in action bar
		getActionBar().setTitle("Main Menu");

		//CreateNotification cn = new CreateNotification();
		//Intent intent = new Intent(ModeSelect.this, CreateNotification.class);
		//startActivity(intent);

		//change fonts
		Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/futuram.ttf");
		TextView editText = (TextView) findViewById(R.id.editText);
		TextView personalizeText = (TextView) findViewById(R.id.personalizeText);
		TextView quicklistText = (TextView) findViewById(R.id.quicklistText);
		TextView profText= (Button) findViewById(R.id.btnProfile);
		TextView personbuttonText= (Button) findViewById(R.id.personalizeButton);
		TextView quickbuttonText= (Button) findViewById(R.id.quicklistButton);


		editText.setTypeface(customFont);
		personalizeText.setTypeface(customFont);
		quicklistText.setTypeface(customFont);
		profText.setTypeface(customFont);
		personbuttonText.setTypeface(customFont);
		quickbuttonText.setTypeface(customFont);


		SQLogic conn = new SQLogic(ModeSelect.this);
		conn.open();
		users = conn.getAllUserData();
		conn.close();

		Log.d("stuff", "stuff");

		personalizeButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				if(users.length == 0){
					Intent intent = new Intent(ModeSelect.this, LoginView.class);
					intent.putExtra("NoUsers", true);
					intent.putExtra("ModeSelected", "SelectProfile");
					startActivity(intent);
				}
				else
				{
					Intent intent = new Intent(ModeSelect.this, PickProfile.class);
					intent.putExtra("NoUsers", false);
					intent.putExtra("ModeSelected", "SelectProfile");
					startActivity(intent); // Later, this will go to a screen where they either pick a current profile
					// or add a new one
				}
			}
		});

		quicklistButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				startActivity(new Intent("com.example.actearly_revised.QuicklistTabHomePage"));
				//startActivity(new Intent("com.example.actearly_revised.AccordianSampleActivity"));
			}
		});

		profileButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				if(users.length == 0){
					Intent intent = new Intent(ModeSelect.this, LoginView.class);
					intent.putExtra("NoUsers", true);
					intent.putExtra("ModeSelected", "AddEditProfile");
					startActivity(intent);
				}
				else{
					Intent intent = new Intent(ModeSelect.this, PickProfile.class);
					intent.putExtra("NoUsers", false);
					intent.putExtra("ModeSelected", "AddEditProfile");
					startActivity(intent);				
				}
			}
		});

	}

	@Override
	public void onRestart(){
		super.onRestart();
		SQLogic conn = new SQLogic(ModeSelect.this);
		conn.open();
		users = conn.getAllUserData();
		conn.close();
	}


	/*	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_login_view, menu);
		return true;
	} */
}
